
import time
import schedule
import utils.twitter_csv_util as twitter_csv_util
import crawler.query_twitter as query_twitter
from utils.chrome_util import chrome
import atexit
from log.logger import logger

intervals_second = 60*2

def twitter_query():
    users = twitter_csv_util.get_all_users()
    for user in users:
        query_twitter.query(user[0])
    logger.info("-----------------------------------")

@atexit.register
def exit():
    chrome.quit()

if __name__ == '__main__':
    twitter_query()
    schedule.every(int(intervals_second)).seconds.do(twitter_query)
    while True:
        schedule.run_pending()
        time.sleep(1)